<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>关闭 cURL 共享句柄</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.curl-share-close" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">curl_share_close</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.5.0, PHP 7)</p><p class="refpurpose"><span class="refname">curl_share_close</span> &mdash; <span class="dc-title">关闭 cURL 共享句柄</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.curl-share-close-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>curl_share_close</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$sh</code></span>
   ) : <span class="type"><span class="type void">void</span></span></div>

  <p class="para rdfs-comment">
   关闭一个 cURL 共享句柄并且释放所有的资源。
  </p>

 </div>


 <div class="refsect1 parameters" id="refsect1-function.curl-share-close-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<code class="parameter">sh</code></dt>

    <dd>

     <p class="para">
      由<span class="function"><a href="curl_share_init.html" class="function">curl_share_init()</a></span>创建的 cURL 共享句柄。
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.curl-share-close-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   没有返回值。
  </p>
 </div>

 
<div class="refsect1 examples" id="refsect1-function.curl-share-close-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5254">
    <p><strong>Example #1 <span class="function"><a href="curl_share_setopt.html" class="function">curl_share_setopt()</a></span> 函数范例：</strong></p>
    <div class="example-contents"><p>
     以下范例将会创建一个 cURL 共享句柄，并且往其中添加两个 cURL 句柄，最后共享这两个 cURL 句柄的 cookie 数据运行。
    </p></div>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">//&nbsp;Create&nbsp;cURL&nbsp;share&nbsp;handle&nbsp;and&nbsp;set&nbsp;it&nbsp;to&nbsp;share&nbsp;cookie&nbsp;data<br /></span><span style="color: #0000BB">$sh&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_share_init</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">curl_share_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$sh</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLSHOPT_SHARE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURL_LOCK_DATA_COOKIE</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Initialize&nbsp;the&nbsp;first&nbsp;cURL&nbsp;handle&nbsp;and&nbsp;assign&nbsp;the&nbsp;share&nbsp;handle&nbsp;to&nbsp;it<br /></span><span style="color: #0000BB">$ch1&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://example.com/"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch1</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_SHARE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sh</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Execute&nbsp;the&nbsp;first&nbsp;cURL&nbsp;handle<br /></span><span style="color: #0000BB">curl_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch1</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Initialize&nbsp;the&nbsp;second&nbsp;cURL&nbsp;handle&nbsp;and&nbsp;assign&nbsp;the&nbsp;share&nbsp;handle&nbsp;to&nbsp;it<br /></span><span style="color: #0000BB">$ch2&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">curl_init</span><span style="color: #007700">(</span><span style="color: #DD0000">"http://php.net/"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_setopt</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch2</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">CURLOPT_SHARE</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$sh</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Execute&nbsp;the&nbsp;second&nbsp;cURL&nbsp;handle<br />//&nbsp;&nbsp;all&nbsp;cookies&nbsp;from&nbsp;$ch1&nbsp;handle&nbsp;are&nbsp;shared&nbsp;with&nbsp;$ch2&nbsp;handle<br /></span><span style="color: #0000BB">curl_exec</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch2</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Close&nbsp;the&nbsp;cURL&nbsp;share&nbsp;handle<br /></span><span style="color: #0000BB">curl_share_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$sh</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;Close&nbsp;the&nbsp;cURL&nbsp;handles<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch1</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">curl_close</span><span style="color: #007700">(</span><span style="color: #0000BB">$ch2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

   </div>
  </p>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.curl-share-close-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member"><span class="function"><a href="curl_share_init.html" class="function" rel="rdfs-seeAlso">curl_share_init()</a> - 初始化一个 cURL 共享句柄。</span></li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>